package com.shf.film.service.impl;

import java.util.List;

import org.apache.commons.logging.LogFactory;

import com.shf.film.common.SearchCondition;
import com.shf.film.dao.UserDao;
import com.shf.film.exception.DAOException;
import com.shf.film.exception.ServiceException;
import com.shf.film.po.User;
import com.shf.film.service.UserService;

public class UserServiceImpl extends ServiceImpl implements UserService{

	private UserDao userDao;
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}


	@Override
	public User login(SearchCondition condition) throws DAOException, ServiceException {
		List<User> result = userDao.find("from User where code=? and pwd=?",new Object[]{condition.getCondition().get("code"),condition.getCondition().get("pwd")});
		if(result!=null && result.size()>0)return result.get(0);
		return null;
	}


	@Override
	public List<User> getUsers() throws DAOException, ServiceException {
		return userDao.find("from User");
	}


	@Override
	public void setLog() {
		log = LogFactory.getLog(this.getClass());
	}

}
